/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package main.NER;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import main.KBProcess.Fragment;
import main.Ontology.ElementOntologySet;

/**
 *
 * @author Isaac Osesina
 */
public interface Branch extends Fruit, Serializable, Cloneable {

    ElementOntologySet getBranchID();

    Branch setParent(Branch parent);

    Branch getParent();

    Branch addChild(ElementOntologySet branchID, boolean append, Integer freq, Fragment fragment);

    Branch addChild(ElementOntologySet branchID);


    /**
     * Returns the branch of the given ID attribute value (label).
     * @param elementID
     *
     * @return branch of the given ID attribute value (label)
     */
    Branch childByID(ElementOntologySet branchID);

    /**
     * Returns the number of child <code>Branch</code> instances that this branch
     * contains.
     *
     * @return the number of branches this branch contains
     */

    int childCount();


    /**
     * Returns an iterator through the children of this branch
     *
     * @return an iterator through the children of this branch
     */
    Iterator<? extends Branch> branchIterator();

    /**
     * Removes the given <code>Branch</code> if the branch is an immediate child
     * of this branch.
     * @param node
     *            is the given node to be removed
     *
     * @return true if the node was removed
     */
    Branch remove(Branch branch);

    Branch remove(ElementOntologySet branchID);

    void updateChildren(Branch branch);

    void updateSisters(Branch sister);

    List<Branch> getChildren();

    /**
     * Returns true if <code>Branch</code> instance contains any child
     *
     * @return the number of branches this branch contains
     */
    boolean hasChildren();
    boolean isLeaf();

    /**
     * Updates the <code>Fruit</code> of the given <code>Branch</code> if the branch if on exists
     * @param node
     *            is the given node to be removed
     *
     * @return <code>Branch</code>
     */
    Branch updateFruit_Terminator(ElementOntologySet branchID, Fragment fragment);

    /**
     * <P>Returns all <code>Branches<\code> with no children</P>
     * @return
     */
    List<Branch> getLeafs();

    /**
     * <P>Returns all <code>Branches<\code> having Fruits with terminator = true.
     * These are branches indicate entity types where the contexts here</P>
     * @return
     */
    List<Branch> getBranchesWithTerminatorFruit();

    Set<Branch> getAmbiguousLeafBranches();

    List<Branch> youngestBranches() ;

    @Override
	boolean isAmbiguous();

    public int countDescendants();

    public List<ElementOntologySet> youngestDescendant();

    public int depth();

}
